home *** CD-ROM | disk | FTP | other *** search
- From: jpotter@falcon.lhup.edu (John E. Potter)
- Message-ID: <4if8u9$6lf@jake.esu.edu>
- X-Original-Date: 16 Mar 1996 20:39:37 GMT
- Path: in2.uu.net!bounce-back
- Date: 17 Mar 96 03:59:27 GMT
- Approved: fjh@cs.mu.oz.au
- Newsgroups: comp.std.c++
- Subject: Template instantiation
- Organization: East Stroudsburg University, Pennsylvania
- X-Newsreader: TIN [version 1.2 PL2]
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBFAgUBMUuOJ+EDnX0m9pzZAQGBbAF8DlgVvdb19Rq9iOUPCDb80L0FhUFfNBMN
- VUuXwY5qS8wzv5i3GXU6UQwBavy5DTMG
- =gaDP
-
- I have only found one compiler which accepts the following. The others
- attempt to instantiate class N prior to completing class L. As I read
- DWP-14.3 [temp.inst], class N<int> should not be instantiated in the
- following code. It would be instantiated when some class L<int> function
- used an N<int>.
-
- template <class T> class N;
- template <class T> class L {
- public :
- // ...
- private :
- N<T>* ptr;
- };
- template <class T> class N {
- private :
- N (T, const L<T>&);
- L<T> next; // error L<int> incomplete type, size unknown
- T data;
- friend class L<T>;
- };
- int main () {
- L<int> l;
- }
-
- Do I have one correct compiler that accepts it, several correct compilers
- which reject it, or (I hope not) all correct compilers because it is not
- specified?
-
- If the latter, is there any standard way to make this portable. I can
- change ptr to a void* and reinterpret_castrate everything, but that is
- not very pleasing.
-
- Thanks,
- John
- ---
- [ comp.std.c++ is moderated. To submit articles: try just posting with ]
- [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
- [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
- [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
- [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
-